﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class user_uPassWord : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            if (Session["wj_User"] == null)
            {
                Response.Redirect("../uPassport.aspx");
            }
        }
    }
    protected void btnAdmin_Edit_Click(object sender, EventArgs e)
    {
        string user = Session["wj_User"].ToString();
        string strPwd1 = TextBox1.Text.ToString().Trim();
        string strPwd2 = TextBox2.Text.ToString().Trim();

        Md5Pw md5 = new Md5Pw();//MD5加密
        string Pwd1 = md5.Md5(strPwd1);
        string Pwd2 = md5.Md5(strPwd2);
        DataTable dt = Class1.ExecSel("select * from wj_User where wj_User='" + user + "'");
        if (dt.Rows[0]["wj_UserPwd"].ToString().Trim() != Pwd1)
        {
            ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "TestAlert", "alert('旧密码输入不正确。请重新输入！');", true);
        }
        else
        {
            Class1.ExecSql("update wj_User set wj_UserPwd='" + Pwd2 + "' where wj_User='" + user + "'");
            Session.Remove("wj_User");
            ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "TestAlert", "alert('密码修改成功，请重新登陆！');", true);
        }
    }
}
